package com.lcsc.verification.vo;

import java.io.Serializable;

/**
 * 分页VO
 *
 * @author luohuijun
 * @date 2017/12/10
 * @Copyright 深圳立创电子商务有限公司
 */
public class PageVO<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private static final int SYSTEM_PAGE_SIZE = 20;

    /**
     * 第几页
     */
    private int currPage = 1;

    /**
     * 每页行数
     */
    private int pageRow = SYSTEM_PAGE_SIZE;

    /**
     * 总页数
     */
    private int totalPage;

    /**
     * 总行数
     */
    private long totalRow;

    /**
     * 分页数据列表
     */
    private T dataList;

    public PageVO() {
    }

    public PageVO(long totalRow, T dataList) {
        this.totalRow = totalRow;
        this.dataList = dataList;
        this.totalPage = (((int) this.totalRow - 1) / this.pageRow) + 1;
    }

    public PageVO(long totalRow, T dataList, int currPage, int pageRow) {
        this.totalRow = totalRow;
        this.dataList = dataList;
        this.pageRow = pageRow;
        this.currPage = currPage;
        this.totalPage = (((int) this.totalRow - 1) / this.pageRow) + 1;
    }

    public int getCurrPage() {
        return currPage;
    }

    public void setCurrPage(int currPage) {
        if (currPage <= 0) {
            this.currPage = 1;
        } else {
            this.currPage = currPage;
        }
    }

    public int getPageRow() {
        return pageRow;
    }

    public void setPageRow(int pageRow) {
        this.pageRow = pageRow;
    }

    public long getTotalRow() {
        return totalRow;
    }

    public void setTotalRow(long totalRow) {
        this.totalRow = totalRow;
        if (this.totalRow > 0 && this.pageRow > 0 && this.totalPage == 0) {
            this.totalPage = (((int) this.totalRow - 1) / this.pageRow) + 1;
        }
    }

    public T getDataList() {
        return dataList;
    }

    public void setDataList(T dataList) {
        this.dataList = dataList;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

}
